package com.youu.youu.portal.controller;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.context.ServletContextAware;

import com.baidu.ueditor.ActionEnter;

@Controller
@RequestMapping("/ued")
public class UeditorController implements ServletContextAware {
    private String rootPath;

    @ResponseBody
    @RequestMapping("/ueditor")
    public String ueditorConfig(HttpServletRequest request, HttpServletResponse response) {
        //System.out.println("读UEditor配置");
        rootPath = request.getSession().getServletContext().getRealPath("/");
        return new ActionEnter(request, rootPath, UeditorController.class.getClassLoader()
            .getResource("ueditor.config.json").getPath()).exec();
    }
    
    @Override
    public void setServletContext(ServletContext servletContext) {
        rootPath = servletContext.getRealPath("/");
    }
}